package com.lirh.mysql.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lirh.mysql.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ProductDao extends BaseMapper<Product> {

    @Update("update product set stock=stock-#{qnantity} where id=#{productId}")
    public void decreaseProduct(@Param("productId") Integer productId,@Param("qnantity") Integer quantity);


    @Select("select * from product where id=#{id} for update")
    public Product selectById(@Param("id") Integer id);

}
